/*
 * @Description:
 * @Version: 2.0
 * @Autor: wsh
 * @Date: 2023-06-20 16:06:20
 * @LastEditors: uphldjx 1373577124@qq.com
 * @LastEditTime: 2024-04-23 17:30:13
 */
import { uploadType } from '@/utils/util'
import apiMod from '@/apiMod/index'


// 列表
const tableConfig = {
	stripe: true,
	border: true,
	maxHeight: '80vh',
	columns: [
		{ label: '归档时间', prop: 'filingTime' },
		{ label: '创建人', prop: 'createUserName' },
		{ label: '创建时间', prop: 'createTime' },
		// { label: '引用模板', prop: 'templateName', width: 220 },
		{
			label: '操作',
			prop: 'menu',
			width: 300,
			fixed: 'right',
		},
	],
}

export const api = {
	index: 'view_zwglTaskDataFiling_page',
}
export const formateBuilData = (form) => {
	let query = {
		...form,
		buildInfo: undefined,
	}
	if (form.buildInfo && form.buildInfoText) {
		query.checkinBuilding = form.buildInfo[0]
		query.checkinFloor = form.buildInfo[1]
		query.checkinRoom = form.buildInfo[2]
		query.checkinBed = form.buildInfo[3]
	}
	return query
}

export const baseConfig = {
	pageName: '归档管理',
	// 数据字典
	dictcodes: ['',],
	rowKey: 'id',
	tipLabel: 'oldmanName',
	addLabel: '创建',
	api: {
		...api,
	},
	auth: {
		...api,
	},
	menuAction: [
		{
			label: '预约入住',
			type: 'primary',
			operate: 'appoint',
			auth: 'view_zwglTaskDataFiling_page',
			show: false,
		},
	],
	// 当前行操作按钮
	menuBtn: [
		{
			label: '查看详情',
			type: 'primary',
			operate: 'detail',
			auth: api.index,
			text: true,
			show: true,
		}
    ],
	dialogConfig: {
		width: '80%',
	},
	// 搜索
	searchConfig: {
		inline: true,
		showBtn: true,
		labelPosition: 'left',
		column: [
			{ label: '归档时间', prop: 'filingTimeBetween',format:"YYYY年MM月DD",valueFormat:"YYYY-MM-DD", type: 'daterange', span: 12 },
		],
	},
	// 列表
	tableConfig,
	onLoadFormate: async (arr) => {
		const tableData = arr.map((item) => {
			return {
				...item,
				buildInfo: [item.checkinBuilding, item.checkinFloor, item.checkinRoom, item.checkinBed],
				buildInfoText: [item.checkinBuilding, item.checkinFloor, item.checkinRoom, item.checkinBed].join('/'),
			}
		})
		return Promise.resolve(tableData)
	},
	beforeOnLoadFormate(form) {
		if(form.filingTimeBetween){
			form.filingTimeBetween = form.filingTimeBetween.join(",")
		}
		return new Promise((resolve, reject) => {
			resolve(formateBuilData(form))
		})
	},
}
